#define _CRT_SECURE_NO_WARNINGS 1

// https://www.luogu.com.cn/problem/P3406

#include <iostream>
using namespace std;

typedef long long int LL;

const int N = 1e5 + 11;

int n , m;

LL a[N];
LL f[N];

int main()
{
	cin >> n >> m;

	int x;
	cin >> x;
	for (int i = 1; i < m; ++i)
	{
		int y = 0;
		cin >> y;

		if (x < y)
		{
			++f[x];
			--f[y];
		}
		else
		{
			--f[x];
			++f[y];
		}
		x = y;
	}

	for (int i = 1; i <= n; ++i)
	{
		f[i] += f[i - 1];
	}

	LL ret = 0;

	for (int i = 1; i < n; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		
		ret += min(a * f[i], c + b * f[i]);
	}

	cout << ret << endl;

	return 0;
}